/**
 * 
 */
package com.gosophia.orgManagement.action;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.gosophia.commons.web.action.BaseSupportAction;
import com.gosophia.commons.web.logAnnotation.LogRecord;
import com.gosophia.organizationManagement.dto.OrganizationDTO;
import com.gosophia.organizationManagement.ws.OrganizationManagementWebService;
import com.opensymphony.xwork2.ActionContext;

/**
 * 添加同级机构用action
 * @author wangxinbing
 * @since  2010-12-31
 *  Copyright (c) 2010 Gosophia corporation All Rights Reserved
 */
@Controller("AddEQLevelOrganizationAction")
@Scope("prototype")
public class AddEQLevelOrganizationAction extends BaseSupportAction {
    private static final long serialVersionUID = 1L;
    @Autowired
    private OrganizationManagementWebService organizationManagementWebService;
    private Long toId;
    private OrganizationDTO organizationDTO;
    private Long orgId;
    private List<OrganizationDTO> organizationDTOs;
    @LogRecord(eventAction="机构管理-添加同级机构",eventTarget="organizationDTO")
    @Override
    public String _execute()throws Exception{
        organizationDTOs = organizationManagementWebService.addEQLevelOrganization(organizationDTO, toId);
        if(organizationDTOs==null||organizationDTOs.size()<1){
            super.getRequestResult().setRsltCode("1");
            super.getRequestResult().setMessage("同级机构添加失败");
            return ERROR;
        }
        if(organizationDTOs.get(organizationDTOs.size()-1).getOrgId()!=null){
            super.getRequestResult().setRsltCode("0");
            super.getRequestResult().setMessage("同级机构添加成功");
            return SUCCESS;
        }else{
            super.getRequestResult().setRsltCode("1");
            super.getRequestResult().setMessage("同级机构添加失败");
            return ERROR;
        }
    }
    
//    @Override
//    public RequestResult getRequestResult() {
//        return requestResult;
//    }

    public Long getToId() {
        return toId;
    }
    public void setToId(Long toId) {
        this.toId = toId;
    }

    public OrganizationDTO getOrganizationDTO() {
        return organizationDTO;
    }

    public void setOrganizationDTO(OrganizationDTO organizationDTO) {
        this.organizationDTO = organizationDTO;
    }

    public Long getOrgId() {
        return orgId;
    }

    public void setOrgId(Long orgId) {
        this.orgId = orgId;
    }

    public List<OrganizationDTO> getOrganizationDTOs() {
        return organizationDTOs;
    }

    public void setOrganizationDTOs(List<OrganizationDTO> organizationDTOs) {
        this.organizationDTOs = organizationDTOs;
    }
    
}
